export default {
    namespaces: 'EnterpriseCertificationResultModel',
    state: {
        status: '',
        msg: ''
    },
    reducers: {
        setStatus(state, { payload }) {
            let { status, msg } = payload
            return {
                ...state,
                status,
                msg
            }
        }
    },
    
    subscriptions: {
        //获取状态
        getStatus({ dispatch, history }) {
            history.listen(location => {
                if(location.pathname === '/EnterpriseCertificationResult') {
                    let { query: {status = '211', msg = '未知错误'} } = location
                    dispatch({
                        type: 'setStatus',
                        payload: {
                            status,
                            msg
                        }
                    })
                }
            })
        }
    }
}